<%@include file="/include/header.jsp" %>
<%@include file="/include/headerBec.jsp" %>
<script>
    function devolverLibro(){
        $( "#dialog:ui-dialog" ).dialog( "destroy" );
        
        $( "#dialog-confirm" ).dialog({
            resizable: false,
            height: 'auto',
            width: 490,
            modal: true,
            buttons: {
                Devolver: function() {
                    $( this ).dialog( "close" );
                    var form = document.getElementById("devolucionLibroForm");
                    form.cmd.value = "devolverLibro";
                    form.submit();
                },
                Cancelar: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
    }
    
    function cargarLibro(codigo){
        var form = document.getElementById("devolucionLibroForm");
        form.prestamo.value = codigo;
        form.cmd.value = "cargarLibro";
        form.submit();
    }
    
    function clean(){
        var form = document.getElementById("devolucionLibroForm");
        form.isbn.value = "";
        form.prestamo.value = "";
        form.fecDevolucion.value = "";
        form.libro.value = "";
        form.cmd.value = "init";
        form.submit();
    }
    
    $(document).ready(function(){
        $("#fechaDev").datepicker({dateFormat:'dd-M-yy', minDate: new Date()});
        $('#fechaDev').datepicker('setDate', '+0');
        var divBg2 = document.getElementById("background2");
        divBg2.style.height = "901px";
    });
</script>
<div class="content">
    <html:form action="/DevolucionLibro" styleId="devolucionLibroForm">
        <html:hidden property="cmd" value="" />
        <html:hidden property="prestamo" />
        <table class="form" width="700px">
            <caption class="titleSeg">Devoluci&oacute;n de Libros</caption>
            <tr class="campos">
                <td class="label">ISBN:&nbsp;&nbsp;</td>
                <td class="control">
                    <html:text property="isbn" styleClass="tinput150" readonly="true" />
                </td>
                <td width="50px"></td>
                <td class="label">Fecha de devoluci&oacute;n:&nbsp;&nbsp;</td>
                <td class="control">
                    <html:text property="fecDevolucion" styleId="fechaDev" styleClass="tinput150" readonly="true" />
                </td>
            </tr>
            <tr class="campos">
                <td class="label">Nombre Libro:&nbsp;&nbsp;</td>
                <td class="control" colspan="4"><html:text property="libro" styleClass="tinput400" readonly="true" /></td>
            </tr>
            <logic:present name="msg">
            <tr>
                <td colspan="5">
                    <html:img src="./images/ok.png"/>&nbsp;
                    <html:messages id="mensaje" name="msg">
                        <bean:write name="mensaje"/>
                    </html:messages>
                </td>
            </tr>
            </logic:present>
            <logic:present name="errors">
            <tr>      
                <td colspan="5" class="errors">
                    <html:img src="./images/error.png"/>&nbsp;
                    <html:messages id="mensaje" name="errors">
                        <bean:write name="mensaje"/>
                    </html:messages>
                </td>
            </tr>
            </logic:present>
            <tr class="botones">
                <td colspan="5">
                    <div style="float: left">
                        <logic:equal name="devolver" value="Y">
                            <html:button property="devolucion" value="Realizar Devolucion" styleClass="button" onclick="devolverLibro();" />
                        </logic:equal>
                        <logic:equal name="devolver" value="N">
                            <html:button property="devolucion" value="Realizar Devolucion" styleClass="button" disabled="true" />
                        </logic:equal>
                        
                        <html:button property="limpiar" value="Limpiar" styleClass="button" onclick="clean();" />
                    </div>
                </td>
            </tr>
        </table>
    </html:form>
    <br />
    <logic:present name="prestamoList" scope="request">
        <center>
            <div style="width:60%; text-align: left">
                <display:table pagesize="10" name="prestamoList" style="width:100%;" class="results" id="results">
                    <display:column property="idPrestamo" title="" sortable="true" decorator="com.uca.sisbec.decorators.DevolucionLibroDecorator"/>
                    <display:column property="isbnLibro" title="Libro" sortable="true"/>
                    <display:column property="fecPrestamo" title="Fecha prestamo" sortable="true"/>
                    <display:column property="fecDevolucion" title="Fecha entrega" sortable="true"/>
                </display:table>
            </div>
        </center>
    </logic:present>
    
    
    <!-- DIVS DE MENSAJES DE VALIDACIONES -->
    <div style="height: 75px; display: none" id="dialog-confirm" title="&iquest;Devolver libro?">
        <table style="font-size: 13px;">
            <tr>
                <td><img src="./images/Warning.png" alt="Atenci&oacute;n" /></td>
                <td style="text-align: justify">&iquest;Est&aacute; seguro que desea devolver el libro?</td>
            </tr>
        </table>
    </div>
    <!-- ******************************** -->
</div>
<%@include file="/include/footerBec.jsp" %>
<%@include file="/include/footer.jsp" %>